import {
  exportUrl,
  downloadTemplateUrl,
  getReviewStatusList,
  getReviewResultList,
  getDefectLevelList
} from "@/api/review/mesDefectiveReview"

import { exportExcel } from "@/utils/judge"

// 列表头按钮配置
export const operateList = [
  {
    name: $i18n.t("common.export"),
    type: "primary",
    icon: "el-icon-download",
    handleName: "export", //点击时返回的标识
    url: exportUrl
    //auth: "auth:operlog:export", //权限字段
  }
  // {
  //   name: "新增",
  //   type: "primary",
  //   icon: "el-icon-circle-plus-outline",
  //   handleName: "add", //点击时返回的标识
  // },
  // {
  //   name: "删除",
  //   type: "danger",
  //   icon: "el-icon-delete",
  //   handleName: "deleteBatch", //点击时返回的标识
  //   isMultiple: true, // isSingle 表示必须选择一项//isMultiple: true, // 表示必须多选
  // },
  // {
  //   name: "导入",
  //   type: "primary",
  //   icon: "el-icon-circle-plus-outline",
  //   handleName: "import", //点击时返回的标识
  // },
]
// 行末按钮配置
export const rowConfig = [
  {
    name: $i18n.t("common.details"),
    type: "info",
    class: "row-btn-info",
    handleName: "detail" //点击时返回的标识
  }
]
// 搜索条件配置
export const searchConfig = {
  inline: true,
  formDesc: {
    reviewCode: {
      type: "input",
      label: $i18n.t("mesDefectiveReview.reviewCode")
    },
    reviewStatus: {
      type: "select",
      label: $i18n.t("mesDefectiveReview.reviewStatus"),
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getReviewStatusList()

        return list.data.result
      }
    },
    orderCode: {
      type: "input",
      label: $i18n.t("mesDefectiveReview.orderCode")
    },
    planCode: {
      type: "input",
      label: $i18n.t("mesDefectiveReview.planCode")
    },

    workshopName: {
      type: "input",
      label: $i18n.t("common.workshopName")
    },
    lineName: {
      type: "input",
      label: $i18n.t("common.lineName")
    },
    equipmentName: {
      type: "input",
      label: $i18n.t("mesDefectiveReview.equipmentName")
    },
    prodName: {
      type: "input",
      label: $i18n.t("mesDefectiveReview.prodName")
    },
    defectLevel: {
      type: "select",
      label: $i18n.t("mesDefectiveReview.defectLevel"),
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getDefectLevelList()
        return list.data.result
      }
    },

    reviewResult: {
      type: "select",
      label: $i18n.t("mesDefectiveReview.reviewResult"),
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getReviewResultList()
        return list.data.result
      }
    }
  }
}
// 新增/删除表单配置
export const formDescDialog = {
  span: 24,
  disabled: false,
  isShowSubmitBtn: true,
  formDesc: {
    reviewCode: {
      type: "input",
      label: $i18n.t("mesDefectiveReview.reviewCode"),
      layout: 12,
      required: false
    },
    planCode: {
      type: "input",
      label: $i18n.t("mesDefectiveReview.planCode"),
      layout: 12,
      required: false
    },
    orderCode: {
      type: "input",
      label: $i18n.t("mesDefectiveReview.orderCode"),
      layout: 12,
      required: false
    },
    workshopCode: {
      type: "input",
      label: $i18n.t("common.workshopCode"),
      layout: 12,
      required: false
    },
    workshopName: {
      type: "input",
      label: $i18n.t("common.workshopName"),
      layout: 12,
      required: false
    },
    lineCode: {
      type: "input",
      label: $i18n.t("common.lineCode"),
      layout: 12,
      required: false
    },
    lineName: {
      type: "input",
      label: $i18n.t("common.lineName"),
      layout: 12,
      required: false
    },
    processCode: {
      type: "input",
      label: $i18n.t("common.processCode"),
      layout: 12,
      required: false
    },
    processName: {
      type: "input",
      label: $i18n.t("common.processName"),
      layout: 12,
      required: false
    },
    equipmentCode: {
      type: "input",
      label: $i18n.t("mesDefectiveReview.equipmentCode"),
      layout: 12,
      required: false
    },
    equipmentName: {
      type: "input",
      label: $i18n.t("mesDefectiveReview.equipmentName"),
      layout: 12,
      required: false
    },
    prodCode: {
      type: "input",
      label: $i18n.t("mesDefectiveReview.prodCode"),
      layout: 12,
      required: false
    },
    prodName: {
      type: "input",
      label: $i18n.t("mesDefectiveReview.prodName"),
      layout: 12,
      required: false
    },
    seriesCode: {
      type: "input",
      label: $i18n.t("mesDefectiveReview.seriesCode"),
      layout: 12,
      required: false
    },
    seriesName: {
      type: "input",
      label: $i18n.t("mesDefectiveReview.seriesName"),
      layout: 12,
      required: false
    },
    rejectQuantity: {
      type: "number",
      label: $i18n.t("mesDefectiveReview.rejectQuantity"),
      layout: 12,
      required: false
    },
    rejectRatio: {
      type: "number",
      label: $i18n.t("mesDefectiveReview.rejectRatio"),
      layout: 12,
      required: false
    },
    defectLevel: {
      type: "select",
      label: $i18n.t("mesDefectiveReview.defectLevel"),
      layout: 12,
      required: false,
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getDefectLevelList()
        return list.data.result
      }
    },
    description: {
      type: "textarea",
      label: $i18n.t("mesDefectiveReview.description"),
      layout: 24,
      required: false
    },
    reviewStatus: {
      type: "select",
      label: $i18n.t("mesDefectiveReview.reviewStatus"),
      layout: 12,
      required: false,
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getReviewStatusList()
        return list.data.result
      }
    },
    reviewResult: {
      type: "select",
      label: $i18n.t("mesDefectiveReview.reviewResult"),
      layout: 12,
      required: false,
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getReviewResultList()
        return list.data.result
      }
    },
    reviewOpinion: {
      type: "input",
      label: $i18n.t("mesDefectiveReview.reviewOpinion"),
      layout: 12,
      required: false
    },
    reviewByName: {
      type: "input",
      label: $i18n.t("mesDefectiveReview.reviewByName"),
      layout: 12,
      required: false
    },
    reviewTime: {
      type: "datetime",
      label: $i18n.t("mesDefectiveReview.reviewTime"),
      layout: 12,
      required: false,
      attrs: {
        valueFormat: "yyyy-MM-dd HH:mm:ss"
      }
    },
    remark: {
      type: "input",
      label: $i18n.t("common.remark"),
      layout: 12,
      required: false
    }
  }
}
//导入数据
export const importFormDescDialog = {
  span: 24,
  disabled: false,
  isShowSubmitBtn: true,
  formDesc: {
    model: {
      type: "button",
      label:"",// $i18n.t("mesDefectiveReview.model"),
      layout: 24,
      required: false,
      title: $i18n.t('common.downloadTemplate'),
      style: {
        color: "#1867c0",
        fontSize: "14px"
      },
      on: {
        click: () => {
          exportExcel(downloadTemplateUrl)
        }
      }
    },
    file: {
      type: "input",
      label: $i18n.t("mesDefectiveReview.file"),
      layout: 24
      // required: true,
    }
  }
}
